﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;

namespace YArchitech.HVAC.AuxiliaryCurve
{
	public class NumberPointsGet : AuxiliaryPointsGet
	{
		public NumberPointsGet(XYZ minArgu, XYZ maxArgu, int xNumberArgu, int yNumberArgu, ref Dictionary<XYZ, XYZ> dicxArgu, ref Dictionary<XYZ, XYZ> dicYArgu) : base(ref dicxArgu, ref dicYArgu)
		{
			this.min = minArgu;
			this.max = maxArgu;
			this.xNumber = xNumberArgu;
			this.yNumber = yNumberArgu;
		}

		public override bool GetPoints()
		{
			if (this.xNumber < 1 && this.yNumber < 1)
			{
				return false;
			}
			double num;
			if (this.xNumber == 1)
			{
				num = Math.Abs(this.max.Y - this.min.Y);
			}
			else
			{
				num = Math.Abs(this.max.Y - this.min.Y) / (double)(this.xNumber - 1);
			}
			double num2;
			if (this.yNumber == 1)
			{
				num2 = Math.Abs(this.max.X - this.min.X);
			}
			else
			{
				num2 = Math.Abs(this.max.X - this.min.X) / (double)(this.yNumber - 1);
			}
			double num3 = this.min.X;
			double num4 = this.max.Y;
			if (num2 > 0.0)
			{
				for (int i = 0; i < this.yNumber; i++)
				{
					XYZ key = new XYZ(num3, this.min.Y, 0.0);
					XYZ value = new XYZ(num3, this.max.Y, 0.0);
					this.dicY.Add(key, value);
					num3 += num2;
				}
			}
			if (num2 > 0.0)
			{
				for (int j = 0; j < this.xNumber; j++)
				{
					XYZ key2 = new XYZ(this.min.X, num4, 0.0);
					XYZ value2 = new XYZ(this.max.X, num4, 0.0);
					this.dicX.Add(key2, value2);
					num4 -= num;
				}
			}
			return true;
		}

		protected XYZ min;

		protected XYZ max;

		protected int xNumber;

		protected int yNumber;
	}
}
